# PyTorch模型开发全流程示例
import torch
from torch import nn
class Classifier(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(768, 10)  # BERT隐藏层维度→分类标签
    def forward(self, embeddings):
        return torch.softmax(self.linear(embeddings), dim=-1)
# 动态调试示例
model = Classifier()
sample_input = torch.randn(32, 768)  # 模拟批量输入
print(model(sample_input).shape)  # 输出: torch.Size([32, 10])